package com.example.sharding.jdbc.repository;

import com.example.sharding.jdbc.db.entity.PayOrderExample;
import com.example.sharding.jdbc.db.entity.PayOrderPO;
import com.example.sharding.jdbc.db.mapper.PayOrderExtMapper;
import com.example.sharding.jdbc.db.mapper.PayOrderMapper;
import com.example.sharding.jdbc.model.req.QueryPayOrderReq;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Repository
public class PayOrderRepository {
    @Resource
    private PayOrderMapper payOrderMapper;
    @Resource
    private PayOrderExtMapper payOrderExtMapper;

    public PayOrderPO queryByOrderId(Long orderId) {
        return payOrderMapper.selectByPrimaryKey(orderId);
    }

    public int insert(PayOrderPO record) {
        return payOrderMapper.insertSelective(record);
    }

    public int batchInsert(List<PayOrderPO> list) {
        return payOrderExtMapper.batchInsert(list);
    }

    public int deleteByOrderId(Long orderId) {
        return payOrderMapper.deleteByPrimaryKey(orderId);
    }

    public int updateByOrderId(PayOrderPO record) {
        return payOrderMapper.updateByPrimaryKeySelective(record);
    }

    public List<PayOrderPO> queryByCond(QueryPayOrderReq req) {
        PayOrderExample example = new PayOrderExample();

        return payOrderMapper.selectByExample(example);
    }
}
